/*
 * JFrameGroupFile.java
 *
 * Created on 8 de junio de 2006, 21:41
 */

package fmap.gui;

import fmap.dao.GroupFileDao;
import fmap.gui.actionListener.ListenerJFrameGroupFile;
import fmap.utils.FormUtils;
import java.util.Vector;
import javax.swing.JList;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author  javi
 */
public class JFrameGroupFile extends javax.swing.JFrame
{
    
    /** Creates new form JFrameGroupFile */
    public JFrameGroupFile ()
    {
        initComponents ();
        
        
        Vector vGroupFile = new GroupFileDao ().selectGroupFile ();
        
        if( vGroupFile.size () > 0 )
        {
            listGroupFile.setListData ( vGroupFile );
        }


        ListenerJFrameGroupFile listener = new ListenerJFrameGroupFile ( this );

        buttonSaveGroupFile.addActionListener ( listener );
        buttonDeleteGroupFile.addActionListener ( listener );
        buttonNewGroupFile.addActionListener ( listener );
        listGroupFile.addListSelectionListener ( listener );
        
        
        FormUtils.centra (this);
        
        setVisible ( true );
        
    }
    
    public JTextField getTextFNameGroupFile ()
    { return textFNameGroupFile; }
    public JTextArea getTextAExtensionGroupFile ()
    { return textAExtensionGroupFile; }
    public JList getListGroupFile ()
    { return listGroupFile; }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        jScrollPane1 = new javax.swing.JScrollPane();
        listGroupFile = new javax.swing.JList();
        textFNameGroupFile = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        textAExtensionGroupFile = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        buttonSaveGroupFile = new javax.swing.JButton();
        buttonNewGroupFile = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        buttonDeleteGroupFile = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Fmap - Grupo de ficheros");
        setAlwaysOnTop(true);
        jScrollPane1.setViewportView(listGroupFile);

        textAExtensionGroupFile.setColumns(20);
        textAExtensionGroupFile.setRows(3);
        jScrollPane2.setViewportView(textAExtensionGroupFile);

        jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel1.setText("Nombre del grupo de ficheros:");

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel2.setText("Extensiones admitidas separadas por comas:");

        buttonSaveGroupFile.setFont(new java.awt.Font("Dialog", 0, 12));
        buttonSaveGroupFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/save.png")));
        buttonSaveGroupFile.setText("Guardar");
        buttonSaveGroupFile.setActionCommand("guardar");
        buttonSaveGroupFile.setMargin(new java.awt.Insets(2, 10, 2, 10));

        buttonNewGroupFile.setFont(new java.awt.Font("Dialog", 0, 12));
        buttonNewGroupFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/document-new.png")));
        buttonNewGroupFile.setText("Nuevo");
        buttonNewGroupFile.setActionCommand("nuevo");
        buttonNewGroupFile.setMargin(new java.awt.Insets(2, 10, 2, 10));

        jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel3.setText("Grupos de ficheros:");

        buttonDeleteGroupFile.setFont(new java.awt.Font("Dialog", 0, 12));
        buttonDeleteGroupFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/cancel.png")));
        buttonDeleteGroupFile.setText("Eliminar");
        buttonDeleteGroupFile.setActionCommand("eliminar");
        buttonDeleteGroupFile.setMargin(new java.awt.Insets(2, 10, 2, 10));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(buttonDeleteGroupFile))
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel1)
                            .add(jLabel2))
                        .add(80, 80, 80))
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE)
                    .add(textFNameGroupFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(buttonNewGroupFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 92, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(buttonSaveGroupFile))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(layout.createSequentialGroup()
                        .add(jLabel3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                    .add(buttonDeleteGroupFile))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(textFNameGroupFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(buttonSaveGroupFile)
                    .add(buttonNewGroupFile))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonDeleteGroupFile;
    private javax.swing.JButton buttonNewGroupFile;
    private javax.swing.JButton buttonSaveGroupFile;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JList listGroupFile;
    private javax.swing.JTextArea textAExtensionGroupFile;
    private javax.swing.JTextField textFNameGroupFile;
    // End of variables declaration//GEN-END:variables
    
}
